﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Converters="clr-namespace:Q2Q.UI.Converters" x:Class="UI.Controls.WindowSystemButtons" 
             mc:Ignorable="d" 
             d:DesignHeight="22" d:DesignWidth="96" Width="Auto" Height="Auto" x:Name="ThisControl" SnapsToDevicePixels="True">
	<UserControl.Resources>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<Converters:WindowStatusToVisibilityConverter x:Key="WindowStatusToVisibilityConverter"/>
		<Style TargetType="{x:Type Button}" BasedOn="{StaticResource CustomButton1}">
			<Setter Property="Background" Value="Transparent" />
			<Setter Property="BorderThickness" Value="0" />
			<Setter Property="SnapsToDevicePixels" Value="True" />
			<Setter Property="Foreground" Value="{DynamicResource SystemButtonForegroundBrush}" />
			<Style.Triggers>
				<Trigger Property="IsMouseOver" Value="True">
					<Setter Property="Foreground" Value="{DynamicResource ForegroundColorBrush}" />
				</Trigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>
	<Grid SnapsToDevicePixels="True">
		<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"  SnapsToDevicePixels="True">

			<Button x:Name="Minimize" Margin="0" Padding="0" Width="30" VerticalAlignment="Stretch" VerticalContentAlignment="Bottom" Click="MinimizeClick" IsTabStop="False">
				<Rectangle Stroke="{Binding Parent.Foreground, RelativeSource={RelativeSource Self}}" SnapsToDevicePixels="True" StrokeThickness="2" Width="10" Margin="0,10,0,0" />
			</Button>
			<StackPanel x:Name="MaxRestoreButtons" Orientation="Horizontal"  SnapsToDevicePixels="True">
				<Button x:Name="Maximize"  Margin="0" Padding="0" Width="30" SnapsToDevicePixels="True" VerticalContentAlignment="Center" VerticalAlignment="Stretch" Click="MaximizeClick" Visibility="{Binding WindowState, ElementName=ThisControl, ConverterParameter=2, Converter={StaticResource WindowStatusToVisibilityConverter}}" IsTabStop="False">
					<Grid RenderTransformOrigin="0.5,0.5"  SnapsToDevicePixels="True">
						<Grid.RenderTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="0.70" ScaleY="0.50"/>
								<SkewTransform/>
								<RotateTransform/>
								<TranslateTransform/>
							</TransformGroup>
						</Grid.RenderTransform>
						<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SnapsToDevicePixels="True" Points="0,0 14,0 14,18 0,18 0,0"  Stroke="{Binding Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="1" StrokeStartLineCap="Round" StrokeLineJoin="Bevel" StrokeEndLineCap="Triangle" Fill="{DynamicResource WindowColorBrush}" />
						<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SnapsToDevicePixels="True" Points="0,2 14,2"		  Stroke="{Binding Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="4" />
					</Grid>
				</Button>
				<Button x:Name="Restore" Margin="0" Padding="0" Width="30" VerticalAlignment="Stretch" SnapsToDevicePixels="True" VerticalContentAlignment="Center" Click="RestoreClick" Visibility="{Binding WindowState, ElementName=ThisControl, ConverterParameter=1, Converter={StaticResource WindowStatusToVisibilityConverter}}" IsTabStop="False">
					<Grid SnapsToDevicePixels="True">
						<Grid RenderTransformOrigin="0.5,0.5" Margin="2,-2,-2,2"  SnapsToDevicePixels="True">
							<Grid.RenderTransform>
								<TransformGroup>
									<ScaleTransform ScaleX="0.45" ScaleY="0.45"/>
									<SkewTransform/>
									<RotateTransform/>
									<TranslateTransform/>
								</TransformGroup>
							</Grid.RenderTransform>
							<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Points="0,0 20,0 20,20 0,20 0,0" SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="2" StrokeStartLineCap="Round" StrokeLineJoin="Bevel" StrokeEndLineCap="Triangle" Fill="{DynamicResource WindowColorBrush}" />
							<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Points="0,2 18,2 18,4 0,4"		 SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="3" />
						</Grid>
						<Grid RenderTransformOrigin="0.5,0.5" Margin="-3,3,3,-3"  SnapsToDevicePixels="True">
							<Grid.RenderTransform>
								<TransformGroup>
									<ScaleTransform ScaleX="0.45" ScaleY="0.45"/>
									<SkewTransform/>
									<RotateTransform/>
									<TranslateTransform/>
								</TransformGroup>
							</Grid.RenderTransform>
							<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Points="0,0 20,0 20,20 0,20 0,0" SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="2" StrokeStartLineCap="Round" StrokeLineJoin="Bevel" StrokeEndLineCap="Triangle" Fill="{DynamicResource WindowColorBrush}" />
							<Polyline HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Points="0,2 18,2 18,4 0,4"		 SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="3" />
						</Grid>
					</Grid>
				</Button>
			</StackPanel>
			<Button x:Name="Close" Margin="0" Padding="0" Width="36" VerticalAlignment="Stretch" VerticalContentAlignment="Top" Click="CloseClick" SnapsToDevicePixels="True"  IsTabStop="False">
				<Grid  SnapsToDevicePixels="True">
					<Polyline HorizontalAlignment="Center" VerticalAlignment="Center" Points="0,0 8,8" SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="1" StrokeEndLineCap="Triangle" StrokeStartLineCap="Triangle" />
					<Polyline HorizontalAlignment="Center" VerticalAlignment="Center" Points="8,0 0,8" SnapsToDevicePixels="True"  Stroke="{Binding Parent.Parent.Foreground, RelativeSource={RelativeSource Self}}" StrokeThickness="1" StrokeEndLineCap="Triangle" StrokeStartLineCap="Triangle" />
				</Grid>
			</Button>
		</StackPanel>
	</Grid>
</UserControl>
